package org.example.datascreen.controller;

import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.example.datascreen.eneity.DTO.SensorDataDTO;
import org.example.datascreen.eneity.Result;
import org.example.datascreen.service.Impl.DeviceServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/Sensor")
public class SensorController {

    @Autowired
    private DeviceServiceImpl deviceService;


    @RequiresAuthentication
    @RequestMapping("/getConductivity")
    public Result<List<SensorDataDTO>> getConductivity(){
        List<SensorDataDTO> list = deviceService.getConductivityData();
        return Result.success(list);
    }

    @RequiresAuthentication
    @RequestMapping("/getNitrogen")
    public Result<List<SensorDataDTO>> getNitrogen(){
        List<SensorDataDTO> list = deviceService.getNitrogenData();
        return Result.success(list);
    }

    @RequiresAuthentication
    @RequestMapping("/getTemperature")
    public Result<List<SensorDataDTO>> getTemperature() {
        List<SensorDataDTO> list = deviceService.getTemperatureData();
        return Result.success(list);
    }

    @RequiresAuthentication
    @RequestMapping("/getMoisture")
    public Result<SensorDataDTO> getMoisture() {
        SensorDataDTO sensorDataDTO = deviceService.getMoistureData();
        return Result.success(sensorDataDTO);
    }
    @RequiresAuthentication
    @RequestMapping("/getpH")
    public Result<SensorDataDTO> getpH() {
        SensorDataDTO sensorDataDTO = deviceService.getPHData();
        return Result.success(sensorDataDTO);
    }


}
